<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<head>
<meta charset="UTF-8" />
</head>
<div id="payIndentModal" class="modal fade" role="dialog"
	aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true"></button>
				<h4 class="modal-title">支付订单</h4>
			</div>
			<div class="modal-body form">
				<form action="" class="form-horizontal form-row-seperated"
					id="payIndentForm" method="post" role="form">
					<input type="hidden" name="indentID" id="indentID">
					<div class="form-group">
						<label class="col-md-4 col-sm-4 control-label">悬赏费用：</label>
						<div class="col-md-5 col-sm-5">
							<input id="addPrice" type="text" value="0" name="addPrice">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">安心宝(5元)：</label>
						<div class="col-sm-1 control-label" style="float: left">
							<input type="checkbox" name="relievedBao" style="float: left"
								value="1" checked="checked" id="relievedBao">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">总费用(元)：</label> <input
							id="totalPrice" type="text" readonly class="form-control"
							style="width: 100px; background: transparent; border: 0">
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-primary"
					onclick="payMeasureIndent('${ctxPath }/indent/payMeasureIndent')">支付宝支付</button>
				<button type="button" class="btn btn-primary" onclick="inputPwd()">余额支付</button>
				<button type="button" class="btn grey-salsa btn-outline"
					onclick="javascript:closePayIndentModal();" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function inputPwd() {
		$('#viewCustomerPasswordDetialModal').modal('show');
	}

	function rechargeSendDatas() {
		var addPrice = $("#payIndentModal  #addPrice").val();
		var indentId = $("#payIndentModal  #indentID").val();
		var totalMoney = $("#payIndentModal  #totalPrice").val();
		var relievedBao = $("#payIndentModal #relievedBao").val();
		var url = '${ctxPath }/payment/balancePay';
		var password = $(
				"#viewCustomerPasswordDetialModal  #txt_customerPasswordNumber")
				.val();
		var encrypedPwd = encryPwd(password);
		var type =
<%=request.getParameter("type")%>
	;
		sendRechargeReqest(indentId, encrypedPwd, addPrice, relievedBao,
				totalMoney, url, type);
	}

	function sendRechargeReqest(indentId, encrypedPwd, addPrice, relievedBao,
			totalMoney, url, type) {
		if (!encrypedPwd) {
			toastr.error("密码不能为空！");
			return;
		}
		$.ajax({
			url : url,
			type : 'post',
			dataType : 'JSON',
			data : {
				indentId : indentId,
				totalMoney : totalMoney,
				password : encrypedPwd,
				addPrice : addPrice,
				relievedBao : relievedBao,
				type : type
			},
			success : function(data) {
				if (data.status == 0) {
					toastr.success("支付成功！");
					//console.log(data.data);
					$("#wallet").find("span").first().html(data.data);
					//$("#toMoney span").html(data.data);
					$("button[name='refresh']").trigger("click");
				} else {
					toastr.error("支付失败！");
				}
			}
		});
		$("#payIndentModal").modal('hide');
	}

	//修改安心宝状态值
	$("#relievedBao").click(function(e) {
		if ($(e.target).is(':checked')) {
			$(this).val(1);
		} else {
			$(this).val(0);
		}
	})
</script>